Skip to content

feat!: rename groups through Groups.Update - #155

Merged
tas50 merged 2 commits into
mainfrom
feat/groups-rename
Nov 27, 2026
Merged

tas50 merged 2 commits into
mainfrom
feat/groups-rename

Conversation

@tas50

@tas50 tas50 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Groups.Update used the group's own name as the URL path, so it couldn't rename a group, although erchef supports renaming:

  • oc_chef_group:update_from_ejson takes the new name from groupname.
  • oc_chef_wm_base:update_from_json → handle_rename answers 201 with Location.
  • pedant covers it (account_group_spec.rb:947-978): the old name 404s, the new one has the same members, and renaming onto an existing name is a 409.

Update is now Update(ctx, name, g), like Clients.Update and Users.Update:

  • The path is the current name, and the new name is sent as groupname.
  • The new name comes from whichever of g.Name/g.GroupName differs from the current name. A group read with Get carries its name in both fields, so changing either one renames it.
  • If the two fields name different new names, the call is refused. If neither changes, the name is kept.
  • g isn't modified, and the actors rewrapping is unchanged.
  • AddMembers/RemoveMembers never rename.
  • erchef echoes the PUT body, which has no name, so Name is filled from GroupName.

erchef doesn't protect the built-in groups (admins, users, clients): an admin can rename them. That's server behavior, so the client doesn't add a guard.

cinc-server-ng doesn't rename (cinc-project/cinc-server-ng#303), so groups/rename is a gap there. The client and user rename gaps now link the same issue.

Breaking: Groups.Update(ctx, g) is now Groups.Update(ctx, name, g).

Test plan

  • Unit tests replay erchef's 201 and echoed body. They cover:
    • renaming through either field
    • refusing two different new names
    • an unmodified caller group
    • member changes that never rename
  • New integration case groups/rename passes against CINC Server 15.10.125 (erchef), together with every other groups/* case
  • go test ./... -race -count=2; groups.go at 100%
  • cd integration && go test ./... (cinc-server-ng, with the gap); golangci-lint in both modules

Groups.Update took the group's own name as the URL path, so it could not
rename. It now takes the current name for the path and sends the new one
as "groupname", the only key erchef reads it from
(oc_chef_group:update_from_ejson). A differing name renames the group:
erchef answers 201 with a Location (oc_chef_wm_base:update_from_json ->
handle_rename) and echoes the PUT body. An empty Name and GroupName keep
the current name; a Name and GroupName that disagree are refused. The
caller's Group is not modified.

cinc-server-ng stores a renaming group PUT under the old name, so
groups/rename is a gap there, as clients/rename and users/rename are.

BREAKING CHANGE: Groups.Update(ctx, g) is now Groups.Update(ctx, name, g).

Signed-off-by: Tim Smith <tsmith84@proton.me>
A group read with Get carries its name in both Name and GroupName, so
changing only one to rename it was refused as a disagreement. Update now
takes the new name from whichever field differs from the current name,
and refuses only two different new names. The rename gaps link
cinc-server-ng#303.

Signed-off-by: Tim Smith <tsmith84@proton.me>
@tas50
tas50 merged commit b7bd210 into main Nov 27, 2026
7 checks passed
@tas50
tas50 deleted the feat/groups-rename branch November 27, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant